#include "Hero.h"
#include "Goblin.h"
#include "Minotaur.h"
#include "Quest.h"
#include "Gameboard.h"
#include <iostream>
#include <string>
using namespace std;



int main(){
	Monster* m;
	Gameboard* board;
	Quest* swordQuest = new Quest("Quest of Glory", 500);
	swordQuest->setDescription("Take up thy sword of destiny and place it upon the altar. Pray to thy gods for deliverance \n from the foes before thee.");
	m = new Goblin ("Jim", 1, 6, 6);
	board = new Gameboard(20,10);
	Hero firstHero("Ser William", 15, 1, 1);
	board->setHero(&firstHero);
	board->placeHeroOnBoard();
	Monster* myFirstMonster = new Goblin ("Goblin grunt", 10, 5, 5);
	Monster* taurus = new Minotaur("Minotaur Beserker", 15, 4, 4);
	board->placeGoblin((Goblin*)myFirstMonster);
	board->placeMinotaur((Minotaur*)taurus);
	Sword* swordOfDestiny = new Sword("Sword of Destiny", 300, 5);
	board->placeRelic(swordOfDestiny);
	board->printBoard();
	
	int randomXLocation = rand()%board->getWidth();
	int randomYLocation = rand()%board->getHeight();

	char choice;
	bool playing;
	playing = true;

	while (playing)
		{

		cout<<"W move up"<<endl;
		cout<<"A move left"<<endl;
		cout<<"D move right"<<endl;
		cout<<"S move down"<<endl;
		cin >> choice;
		if (choice== 'W' || choice == 'w')
			board->moveHeroYAxis(-1);
		else if (choice=='A' || choice == 'a')
			board->moveHeroXAxis(-1);
		else if (choice=='D' || choice == 'd')
			board->moveHeroXAxis(1);
		else if (choice=='S' || choice == 's')
			board->moveHeroYAxis(1);

		board->printBoard();
		
		}
	while(true){
		}
	return 0;
	}


/*
cout<<"I am a hero of level "<< firstHero.getLevel()  <<endl;
		cout<< "My strength is mighty and I strike for " << firstHero.getDamage()  << "points of damage" <<endl;
		cout<<"My current health is " <<firstHero.getHealth() <<endl;

		cout<<"I have a few things I can do: \n" <<endl;
		if (myFirstMonster->getCurrentHealth()>0)
			cout<<"1: Fight a Goblin and gain experience "<<endl;
		if (taurus->getCurrentHealth()>0)
			cout<<"2: Fight a Minotaur and gain experience "<<endl;
		cout<<"3: Heal " <<endl;
		cout<<"4: Hear the quest"<<endl;
		if (!firstHero.isHoldingItem())
			cout<<"5: Equip the sword of destiny"<<endl;
		if (firstHero.isHoldingItem())
			cout<<"6: Pray to improve the sword of destiny"<<endl;
		cout<<"0: quit"<<endl;
		cin >> choice;


		if (choice == 1)
			{
			if(myFirstMonster->isAlive()){
				int dice = rand();
				cout<<"You approach "<<myFirstMonster->getType()<<endl;
				if ((dice%100)>50){
					myFirstMonster->takeDamage(firstHero.getDamage());
					if(myFirstMonster->isAlive()){
						cout<<"You injured the monster!"<<endl;
						cout<<"You did "<<firstHero.getDamage()<<" points of damage "<<endl;
						}
					else
						{
						cout<<"You have defeated the monster!"<<endl;
						firstHero.levelUp();
						}
					}
				else{
					cout<<"You wre injured by the monster!"<<endl;
					firstHero.takeDamage(myFirstMonster->getAttack());
					cout<<"You took "<<myFirstMonster->getAttack()<<" points of damage"<<endl;
					if (firstHero.getHealth()  <= 0){
						cout<<"You have died"<<endl;
						playing = false;
						firstHero.endGame();

						}
					}
				}
			}
		if (choice == 2)
			{
			if (taurus->isAlive()){
				int dice = rand();
				cout<<"You approach the "<<taurus->getType()<<endl;
				if ((dice%100)>50){
					taurus->takeDamage(firstHero.getDamage());
					if(taurus->isAlive()){
						cout<<"You injured the monster!"<<endl;
						cout<<"You did "<<firstHero.getDamage()<<" points of damage "<<endl;
						}
					else
						{
						cout<<"You have defeated the monster!"<<endl;
						firstHero.levelUp();
						}
					}
				else{
					cout<<"You wre injured by the monster!"<<endl;
					firstHero.takeDamage(taurus->getAttack());
					cout<<"You took "<<taurus->getAttack()<<" points of damage"<<endl;
					if (firstHero.getHealth()  <= 0){
						cout<<"You have died"<<endl;
						playing = false;
						firstHero.endGame();

						}
					}
				}
			}
		else if (choice == 3){
			firstHero.heal();

			}
		else if (choice ==4){
			cout<<swordQuest->getDescription()<<endl;
			cout<<"do you accepted?"<<endl;
			cout<<"1: Yes"<<endl;
			cout<<"2: no"<<endl;
			bool quest_choice;
			cin>>quest_choice;
			if (quest_choice == 1)
				swordQuest->setAccepted(true);
			else
				swordQuest->setAccepted(false);
			
			}

		else if (choice ==5){
			if (!firstHero.isHoldingItem())
				firstHero.useSword(swordOfDestiny);
			}
		else if (choice ==6){
			if (firstHero.isHoldingItem()&& swordOfDestiny->isEnhanced()==false ){
				firstHero.layDownSword(swordOfDestiny);
				if(firstHero.enhanceSword(swordOfDestiny))
					{
					swordQuest->setComplete();
					Sword* tmp = new Sword(swordOfDestiny->getName(), swordOfDestiny->getPrice(), swordOfDestiny->getDamage()+5);
					free(swordOfDestiny);
					swordOfDestiny=tmp;
					firstHero.addExperience(swordQuest->getExperience());
					}
				}
			}

		else if (choice == 0){
			playing = false;
			firstHero.endGame();


			}



*/